package com.java.java8.util.functioninterfacedemo;


import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;

/**
 * @author liyanhao
 * @Date 2023-03-26 18:24
 */
@FunctionalInterface
interface BiFuncationDemo2<T, U, R> {
    T replaceAll(BiFunction<? super T,? super U,? extends R> function);
}

class TestBiFuncationDemo2{
    public static void main(String[] args) {
        Map<String, Integer> wordMap = new HashMap<>();
        wordMap.put("hello", 5);
        wordMap.put("world", 5);
        wordMap.put("on", 2);
        wordMap.put("at", 2);

        wordMap.replaceAll((k,v)->{
            if ("on".equals(k) || "at".equals(k)) {
                return 0;
            }else {
                return v;
            }
        });
        System.out.println(wordMap);
    }
}


